package love.yuanmengrobot.wuziqi.Util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * @author zjj
 *数据库连util
 */
public class DbUtil {

	private String dbUrl = "jdbc:oracle:thin:@112.74.190.130:1521:orcl";
	private String dbUser = "scott";
	private String dbPassword = "scott1316";
	private String jdbcName = "oracle.jdbc.OracleDriver";
	private Connection connection = null;
	public Connection getConnection(){
		try {
			Class.forName(jdbcName);
			connection = DriverManager.getConnection(dbUrl, dbUser, dbPassword);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return connection;
	}

	public void closeCon(){
		if(connection != null)
			try {
				connection.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		DbUtil dbUtil = new DbUtil();
		dbUtil.getConnection();
	}

}
